package cn.itcast.tlias.com.tliaswork.config;

import cn.itcast.tlias.com.tliaswork.intercepter.LoginCheckIntercept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//声明注册连接器
@Configuration
public class WebCofig implements WebMvcConfigurer {
    @Autowired
    private LoginCheckIntercept mIntercept;

    //关联注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.
                addInterceptor(mIntercept) //关联拦截器
                .addPathPatterns("/**") //其中/*代表一级路径 /**代表多级路径
                .excludePathPatterns("/login");//不拦截哪些路径
    }
}
